package com.base.data.elasticsearch.core.operation;

import com.google.gson.JsonObject;
import com.base.data.elasticsearch.core.convert.BaseElasticsearchConverter;
import com.base.data.elasticsearch.core.mapping.BaseElasticsearchPersistentEntity;
import org.elasticsearch.client.RestHighLevelClient;

import java.util.Map;

public interface BaseElasticsearchOperation {

    // >>>>>>>>>>>>>>>>>>>> index >>>>>>>>>>>>>>>>>>>>
    Boolean autoMapping();

    /**
     * @return Converter in use
     */
    BaseElasticsearchConverter getElasticsearchConverter();

    /**
     * @return elasticsearch client
     */
    RestHighLevelClient getClient();

    /**
     * Create an index for a class
     * 不允许直接调用，需要兼容之前代码，并且需要保持index_type一致，不要单独创建index,如果有setting,alias其他配置，单独http 配置
     */
    @Deprecated
    <T> boolean createIndex(Class<T> clazz);

    /**
     * Create an index for given indexName
     * 不允许直接调用，需要兼容之前代码，并且需要保持index_type一致，不要单独创建index,如果有setting,alias其他配置，单独http 配置
     */
    @Deprecated
    boolean createIndex(String indexName);

    /**
     * Create an index for given indexName and Settings
     * 不允许直接调用，需要兼容之前代码，并且需要保持index_type一致，不要单独创建index,如果有setting,alias其他配置，单独http 配置
     */
    @Deprecated
    boolean createIndex(String indexName, Object settings);

    /**
     * Create an index for given class and Settings
     * 不允许直接调用，需要兼容之前代码，并且需要保持index_type一致，不要单独创建index,如果有setting,alias其他配置，单独http 配置
     */
    @Deprecated
    <T> boolean createIndex(Class<T> clazz, Object settings);

    <T> boolean updateTypeMapping(String index, String type, Class<T> tClass, JsonObject existPropJson);
    <T> boolean updateTypeMapping(Class<T> tClass, JsonObject existPropJson);

    /**
     * Create mapping for a class
     */
    @Deprecated
    <T> boolean putMapping(Class<T> clazz);

    /**
     * Create mapping for a given indexName and type
     */
    @Deprecated
    boolean putMapping(String indexName, String type, Object mappings);

    /**
     * Create mapping for a class
     */
    @Deprecated
    <T> boolean putMapping(Class<T> clazz, Object mappings);


    /**
     * Get mapping for a class
     */
    @Deprecated
    <T> Map getMapping(Class<T> clazz);

    /**
     * Get mapping for a given indexName and type
     */
    @Deprecated
    Map getMapping(String indexName, String type);

    /**
     * Get settings for a given indexName
     */
    @Deprecated
    Map getSetting(String indexName);

    /**
     * Get settings for a given class
     */
    @Deprecated
    <T> Map getSetting(Class<T> clazz);

    /**
     * Deletes an index for given entity
     */
    @Deprecated
    <T> boolean deleteIndex(Class<T> clazz);

    /**
     * Deletes an index for given indexName
     */
    @Deprecated
    boolean deleteIndex(String indexName);

    /**
     * check if index is exists
     */
    //done
    <T> boolean indexExists(Class<T> clazz);

    /**
     * check if index is exists for given IndexName
     *
     * @param indexName
     * @return
     */
    //done
    boolean indexExists(String indexName);

    /**
     * check if type is exists in an index
     *
     * @param index
     * @param type
     * @return
     */
    //done
    JsonObject typeExists(String index, String type);


    // <<<<<<<<<<<<<<<<<<<< index <<<<<<<<<<<<<<<<<<<<

    BaseElasticsearchPersistentEntity getPersistentEntityFor(Class clazz);

}
